<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>MVP</title>
  <script src="./jquery.js"></script>
</head>
<body>
  <div id="app">
    <input type="text" id="input">
    <button id="btn">提交</button>
    <ul id="list"></ul>
  </div>

  <script>
    // MVP 模式写TodoList
    function Page() {}
    $.extend(Page.prototype, {
      init: function() {
        this.bindEvents();
      },
      bindEvents: function() {
        var btn = $('#btn');
        btn.on('click', $.proxy(this.BtnClick, this));
      },
      BtnClick: function() {
        var inputElem = $('#input');
        var inputVal = inputElem.val();
        var ulElem = $('#list');

        ulElem.append('<li>'+ inputVal +'</li>');
        inputElem.val('');
      }
    })
    
    var page = new Page();
    page.init();
  </script>


</body>
</html>